<?php
namespace app\api\model;

use think\Db;
use think\Model;

class PictureModel extends Model
{
      function picturelist() {
        $masters =  Db::name('picture')->select();
        return $masters;
	    }
	    function picturedetail($pictureid) {
        $result = Db::name('picture')->where('pictureid',$pictureid)->find();
        return $result;
    }
    function reply($userid, $pictureid, $content) {
        $data = ['userid'=>$userid, 'pictureid' => $pictureid, 'content' => $content];
        $result = Db::name('reply')->insertGetId($data);
        return ['replyid'=>$result];
    }

    function issuepicture($userid,$picname,$intro,$date,$picture1) {
        $data = ['userid'=>$userid, 'state'=>0, 'data'=>$date, 'picturename'=>$picname,'intro'=>$intro, 'picture1' => $picture1];
        $result = Db::name('picture')->insert($data);
        if ($result) {
            return 1;
        }else{
            return 0;
        }
    }
    function getpicture($userid) {
        $result =  Db::name('picture')
            ->where("userid",$userid)
            ->select();
        return $result;
    }

    function myPicture($userid){
          $res = Db::name('picture')
              ->where('userid',$userid)
              ->select();
          return $res;
    }

    function deleteMyPicture($pictureid){
          $res = Db::name('picture')
              ->where('pictureid',$pictureid)
              ->delete();
          return $res;
    }
}